/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

import Datos.Usuario;

/**
 * 
 * @author Pablo
 */
public class Login extends javax.swing.JFrame {

	/**
	 * Creates new form Login
	 */
	public Login() {
		initComponents();
		this.setLocationRelativeTo(null);// Para que la ventana aparezca en el
											// centro de la pantalla
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		jLabel1 = new javax.swing.JLabel();
		jLabel2 = new javax.swing.JLabel();
		jLabel3 = new javax.swing.JLabel();
		jLabel4 = new javax.swing.JLabel();
		username1 = new javax.swing.JTextField();
		username2 = new javax.swing.JTextField();
		password1 = new javax.swing.JPasswordField();
		password2 = new javax.swing.JPasswordField();
		buttonAcceder = new javax.swing.JButton();
		jLabel5 = new javax.swing.JLabel();
		jButton1 = new javax.swing.JButton();
		jLabel6 = new javax.swing.JLabel();

		this.setTitle("Login");

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setResizable(false);

		jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		jLabel1.setForeground(new java.awt.Color(255, 255, 255));
		jLabel1.setText("Jugador 1 : ");
		getContentPane().add(jLabel1);
		jLabel1.setBounds(100, 140, 83, 17);

		jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		jLabel2.setForeground(new java.awt.Color(255, 255, 255));
		jLabel2.setText("Jugador 2 :");
		getContentPane().add(jLabel2);
		jLabel2.setBounds(100, 240, 80, 17);

		jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		jLabel3.setForeground(new java.awt.Color(255, 255, 255));
		jLabel3.setText("Password :");
		getContentPane().add(jLabel3);
		jLabel3.setBounds(100, 190, 76, 17);

		jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
		jLabel4.setForeground(new java.awt.Color(255, 255, 255));
		jLabel4.setText("Password :");
		getContentPane().add(jLabel4);
		jLabel4.setBounds(100, 290, 76, 17);

		getContentPane().add(username1);
		username1.setBounds(210, 130, 90, 30);

		getContentPane().add(username2);
		username2.setBounds(210, 230, 90, 30);

		getContentPane().add(password1);
		password1.setBounds(210, 180, 90, 30);

		getContentPane().add(password2);
		password2.setBounds(210, 280, 90, 30);

		buttonAcceder.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
		buttonAcceder.setText("Acceder");
		buttonAcceder.setOpaque(false);
		buttonAcceder.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				buttonAccederActionPerformed(evt);
			}
		});
		getContentPane().add(buttonAcceder);
		buttonAcceder.setBounds(160, 330, 81, 25);

		jLabel5.setFont(new java.awt.Font("hooge 05_53", 1, 48)); // NOI18N
		jLabel5.setForeground(new java.awt.Color(255, 255, 255));
		jLabel5.setText("REVERSI");
		getContentPane().add(jLabel5);
		jLabel5.setBounds(80, 50, 249, 42);

		jButton1.setText("Registrarse");
		jButton1.setOpaque(false);
		jButton1.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton1ActionPerformed(evt);
			}
		});
		getContentPane().add(jButton1);
		jButton1.setBounds(0, 0, 100, 23);

		jLabel6.setIcon(new javax.swing.ImageIcon(
				"C:..\\Reversi\\images\\board1.gif")); // NOI18N
		getContentPane().add(jLabel6);
		jLabel6.setBounds(0, 0, 410, 410);

		pack();
	}// </editor-fold>

	private void buttonAccederActionPerformed(java.awt.event.ActionEvent evt) {
		Menu m = new Menu();
		m.setVisible(true);
		this.setVisible(false);

	}
	
	

	public void cargarFichero() throws IOException {

		try {
			FileOutputStream fso = new FileOutputStream("Nombres.DAT");
			ObjectOutputStream ffis = new ObjectOutputStream(fso);
			ffis.writeObject(username1.getText());
			ffis.writeObject(username2.getText());
			ffis.close();

		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	/*
	 * public Usuario obtenerNombre1(){ Usuario u1 = new Usuario (0, title,
	 * title, title, rootPaneCheckingEnabled, title, defaultCloseOperation,
	 * defaultCloseOperation, defaultCloseOperation, null);
	 * u1.setNombre(username1.getText()); return u1; }
	 */
	/*
	 * public Usuario obtenerNombre2(){ Usuario u2= new Usuario (0, title,
	 * title, title, rootPaneCheckingEnabled, title, defaultCloseOperation,
	 * defaultCloseOperation, defaultCloseOperation, null);
	 * u2.setNombre(username2.getText()); return u2; }
	 */

	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
		Registro r = new Registro();
		r.setVisible(true);
	}

	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String args[]) {
		/* Set the Nimbus look and feel */
		// <editor-fold defaultstate="collapsed"
		// desc=" Look and feel setting code (optional) ">
		/*
		 * If Nimbus (introduced in Java SE 6) is not available, stay with the
		 * default look and feel. For details see
		 * http://download.oracle.com/javase
		 * /tutorial/uiswing/lookandfeel/plaf.html
		 */
		try {
			for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager
					.getInstalledLookAndFeels()) {
				if ("Nimbus".equals(info.getName())) {
					javax.swing.UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} catch (ClassNotFoundException ex) {
			java.util.logging.Logger.getLogger(Login.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (InstantiationException ex) {
			java.util.logging.Logger.getLogger(Login.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (IllegalAccessException ex) {
			java.util.logging.Logger.getLogger(Login.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (javax.swing.UnsupportedLookAndFeelException ex) {
			java.util.logging.Logger.getLogger(Login.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		}
		// </editor-fold>

		/* Create and display the form */
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new Login().setVisible(true);
			}
		});
	}

	// Variables declaration - do not modify
	private javax.swing.JButton buttonAcceder;
	private javax.swing.JButton jButton1;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JLabel jLabel4;
	private javax.swing.JLabel jLabel5;
	private javax.swing.JLabel jLabel6;
	private javax.swing.JPasswordField password1;
	private javax.swing.JPasswordField password2;
	private javax.swing.JTextField username1;
	private javax.swing.JTextField username2;
	// End of variables declaration
}
